﻿/*****************************************************************************
	SNEGA STG GAME ENGINE 0.7a
	Copyright (C) 2009, Xiaohan Tian (snega0223)
	
	http://code.google.com/p/sng-actionscript-stg-engine/
	
	This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License(LGPL) as
	published by the Free Software Foundation, either version 3 of the 
	License, or(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.
	
	You should have received a copy of the GNU Lesser General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

package com.sng.stg.game.enemy.action 
{
	import com.sng.stg.game.bullet.EnemyBullet;
	import com.sng.stg.game.enemy.Enemy;
	import com.sng.stg.game.StageViewer;
	import flash.display.BitmapData;
	
	/**
	 * ...
	 * @author snega
	 */
	public class EnemyFireType1 extends EnemyAction
	{
		protected var _bitmapData:BitmapData = null;
		protected var _pixelSnapping:String = "auto";
		protected var _smoothing:Boolean = false;
		
		protected var _duration:int, _ax:int, _ay:int, _radius:Number;
		
		public function EnemyFireType1(monitorLife:Boolean, value:int, enemy:Enemy, duration:int = 60, ax:int = 0, ay:int = 0, radius:Number = 1, bitmapData:BitmapData = null, pixelSnapping:String = "auto", smoothing:Boolean = false) 
		{
			super(monitorLife, value, enemy);
			
			this._bitmapData = bitmapData;
			this._pixelSnapping = pixelSnapping;
			this._smoothing = smoothing;
			
			this._ax = ax;
			this._ay = ay;
			this._duration = duration;
			
			this._radius = radius;
		}
		
		override public function execute():void {
			trace("[Action] (" + this._time + ") Hit EnemyFireType1.");
			
			var currStage:StageViewer = this._enemy._currStage;
			
			var bullet:EnemyBullet = new EnemyBullet(this._enemy._currStage, this._radius, this._bitmapData, this._pixelSnapping, this._smoothing);
			bullet.x = this._enemy.x;
			bullet.y = this._enemy.y;
			bullet._vx = (currStage._player.x - this._enemy.x) / this._duration;
			bullet._vy = (currStage._player.y - this._enemy.y) / this._duration;
			bullet._ax = this._ax;
			bullet._ay = this._ay;
			
			currStage._enemyBulletList.push(bullet);
			currStage._2dElement.addChild(bullet);
		}
		
	}
	
}